#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
bool isp(string str) {
  string tmp = str;
  reverse(str.begin(), str.end());
  return tmp == str;
}
int main() {
  string str;
  cin >> str;
  int a = stoi(str.substr(0, 2));
  int b = stoi(str.substr(3));
  int ans = 0;
  while (1) {
    string sa = to_string(a);
    if (sa.length() == 1) sa = "0" + sa;
    string sb = to_string(b);
    if (sb.length() == 1) sb = "0" + sb;
    string tmp = sa + ":" + sb;
    if (isp(tmp)) {
      cout << ans << endl;
      break;
    }
    b++;
    if (b == 60) {
      a++;
      b = 0;
      if (a == 24) {
        a = 0;
      }
    }
    ans++;
  }
  return 0;
}
