#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string str;
  cin >> str;
  int hour, min_;
  int hour_rev, min_rev;
  hour_rev = 0;
  min_rev = 0;
  hour = 0;
  min_ = 0;
  bool found = false;
  for (int i = 0; i < str.length(); i++) {
    if (str[i] == ':') {
      found = true;
      continue;
    }
    int no = (str[i] - '0');
    if (found == false)
      hour = (hour * 10) + no;
    else
      min_ = (min_ * 10) + no;
  }
  int temp;
  temp = hour;
  while (temp != 0) {
    int temp_no = temp % 10;
    hour_rev = (hour_rev * 10) + temp_no;
    temp /= 10;
  }
  if (hour <= 9) {
    hour_rev = hour_rev * 10;
  }
  temp = min_;
  while (temp != 0) {
    int temp_no = temp % 10;
    min_rev = (min_rev * 10) + temp_no;
    temp /= 10;
  }
  if (min_ <= 9) {
    min_rev = min_rev * 10;
  }
  vector<int> ref_time;
  ref_time.push_back(0);
  int xtratime = 0;
  for (int i = 1; i <= 23; i++) {
    int hour_minutes = i * 60;
    xtratime += 10;
    if (xtratime < 60) {
      ref_time.push_back(hour_minutes + xtratime);
    }
    if (i + 1 == 10) {
      xtratime = 1 - 10;
    }
    if (i + 1 == 20) {
      xtratime = 2 - 10;
    }
  }
  ref_time.push_back(1440);
  vector<int>::iterator iter;
  iter = lower_bound(ref_time.begin(), ref_time.end(), (hour * 60) + min_);
  cout << (*iter) - ((hour * 60) + min_);
  return 0;
}
